<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // mixin
        const data = [
            { name: 'js', price: 33, click: 5 },
            { name: 'css', price: 5, click: 28 },
            { name: 'html', price: 38, click: 20 },
            { name: 'mysql', price: 99, click: 18 },
            { name: 'node', price: 189, click: 22 },
        ]
        let Tool = {
            max(key) {
                return this.data.sort((a, b) => b[key] - a[key])[0];
            }
        }
        let Arr = {
            count(key) {
                return this.data.reduce((total, item) => total + item[key], 0);
            }
        }
        class Lesson {
            constructor(lessons) {
                this.lessons = lessons;
            }
            get data() {
                return this.lessons;
            }
        }
        Object.assign(Lesson.prototype, Tool, Arr);
        let les = new Lesson(data);
        console.log(les.max('price'));
        console.log(les.count('click'));
    </script>
</body>

</html>